
cc.Class({
    extends: require('wy-Component'),

    properties: {
       
    },

    onLoad(){
    },
   

    start () {

    },

   setOptions(data){
       cc.log('friend',data);
        this.o_data = data;
        this.node.active = !!data;

        cc.loader.load({url:this.o_data.imgUrl,type:'png'},function(err,tex){
            if(!err && this.node){
                this.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(tex);
            }
        }.bind(this))
   },

   clickFriendlyLinks(event){ 
       if(!this.o_data.appKey){
            return global.ErrorLog.upload('appkey'+this.node.name,"friend link appkey error");
       }
       if(CC_WECHATGAME){
            if(this.o_data.preview){
                wx.previewImage({
                urls:[this.o_data.previewUrl]
                })
                return true
            }
            global.Http.get('/game/gameUser','friendlyLinkClick.addCount',{
                appId:this.o_data.appKey,
                area:this.o_data.area,
                sceneName : this.o_data.sceneName,
                appName : this.o_data.appName
            },global.NullFunction)
            wx.navigateToMiniProgram({
                appId: this.o_data.appKey,
                envVersion : 'release',
                path: this.o_data.path, //"trial","release"
                success:function(){
                    console.log('跳转成功')
                    global.Http.get('/game/gameUser','friendlyLinkClick.addOpenCount',this,global.NullFunction)
                }.bind({
                    appId:this.o_data.appKey,
                    area:this.o_data.area,
                    sceneName : this.o_data.sceneName,
                    appName : this.o_data.appName
                   })
            })
            wx.aldSendEvent(this.o_data.appName,{
                appId:this.o_data.appKey,
                area:this.o_data.area,
                sceneName : this.o_data.sceneName,
                appName : this.o_data.appName
            })
       }
    }
});
